package com.bawei.mvc.View;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import com.bawei.mvc.Pertion.BasePresenter;

/**
 * create by ertu
 * create on 2021/7/19
 * description
 */
public abstract class BaseFragment   <P extends BasePresenter> extends Fragment implements IFragment,IView{
    protected P mpresenter;
    View view;
    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view  = inflater.inflate(bandLayouts(), null);
        return view;

    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        initViews();
        initDates();
    }

    @Override
    public void showLaoding() {

    }

    @Override
    public void hideLaoding() {

    }


    @Override
    public void showToast(String msg) {
        Toast.makeText(getContext(),msg,Toast.LENGTH_SHORT).show();
    }

    @Override
    public <T extends View> T findByids(int id) {
        return view.findViewById(id);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        if (mpresenter!=null)
        {
            mpresenter.dinst();
        }
    }
}
